'''
订单类：需求方，功能使用方。
将需求变成订单，订购相关产品。
'''
from abc import abstractmethod
import allPizza  # 用simpleFactory时，在引入到simpleFactory模块的。（此处可看出联系、差别）


class Order(object):
    '''
    创建订单
    '''
    location_name = ''

    @abstractmethod
    def createOrder(self, pizza_name):
        pass

    def orderPizza(self, pizza_name):
        pizza = self.createOrder(pizza_name)
        if pizza is None:
            print("====>> 找不到对应的pizza类型！")
            return
        
        pizza.parpare()
        pizza.bake()
        pizza.pack()


class OrderBJPizza(Order):
    location_name = 'BJ'

    def createOrder(self, pizza_name):
        pizza_name = '%s%sPizza' % (self.location_name, pizza_name)
        if not hasattr(allPizza, pizza_name):
            return None
        
        return getattr(allPizza, pizza_name)()


class OrderLDPizza(Order):
    location_name = 'LD'

    def createOrder(self, pizza_name):
        pizza_name = '%s%sPizza' % (self.location_name, pizza_name)
        if not hasattr(allPizza, pizza_name):
            return None
        
        return getattr(allPizza, pizza_name)()


if __name__ == "__main__":
    # 具体的订购客户操作
    location_type = input("请输入pizza产地：")
    pizza_type = input("请输入pizza种类：")

    # 感觉使用起来并不是很好，所以后面的调用我就省略了。大致思想就是这样。
    pass
